#!/bin/bash echo "VNCCTL - VNC Control script, written by ShALLaX (c) 2003" case "$1" in start) export PATH="$PATH:/usr/X11R6/bin" if [ ! -s "$HOME/.vnc" ] ; then mkdir ~/.vnc fi if [ -s "$HOME/.vnc/started" ] ; then echo "You already have VncServer started, stop it first" fi if [ ! -s "$HOME/.vnc/started" ] ; then vncserver $2 $3 echo "VncServer started" echo > ~/.vnc/started fi ;; stop) if [ ! -s "$HOME/.vnc/started" ] ; then echo "VncServer has not been started for `whoami`" fi if [ -s "$HOME/.vnc/started" ] ; then cat ~/.vnc/`hostname`\:*.pid | tail -n 1 | xargs kill ls ~/.vnc/`hostname`\:*.pid | tail -n 2 | xargs rm -rf rm -rf ~/.vnc/started echo "VncServer Stopped" fi ;; *) echo "usage: vncctl (start | stop)" echo "Only one VNC shell per user, to connect: http://`hostname`:580X" echo "X is the number returned by the script (i.e. `hostname`:X)" ;; esac